const multer = require('multer');
const path = require('path')
const storage = multer.diskStorage({
  destination: function (req, file, cb) {
    // 指定文件存储的目录
    cb(null, 'uploads/');
  },
  filename: function (req, file, cb) {
    // 指定文件的名称，这里使用原文件名加上时间戳
    const uniqueSuffix = Date.now() + '-' + Math.round(Math.random() * 1E9);
    cb(null, uniqueSuffix + path.extname(file.originalname));
  }
});
const upload = multer({ storage: storage });

module.exports = upload;